package org.csu.mypetstore.service;

import org.csu.mypetstore.domain.Cart;
import org.csu.mypetstore.domain.Item;
import org.csu.mypetstore.persistence.UserCartDAO;
import org.csu.mypetstore.persistence.impi.UserCartDAOImpi;

public class CartService {
    private UserCartDAO userCartDAO;
    public  CartService(){
        userCartDAO = new UserCartDAOImpi();
    }

    public void insertNewAccount(String username)
    {
        userCartDAO.insertAccount(username);
    }

    public void updateCartSetQuantity(String username, String itemId,int newQuantity)
    {
        String Quantity = newQuantity+"";
        userCartDAO.updateUserCartByUserName(username,itemId,Quantity);
    }
    public void updateCartAddItem(String username, Item item){
        String itemId = item.getItemId();
        userCartDAO.addCartItem(username,itemId);
    }
    public Cart getCartByUsername(String username){
        return userCartDAO.getUserCartByUserName(username);
    }

    public void removeItemById(String username,String itemId)
    {
        userCartDAO.removeItemById(username,itemId);
    }

    public void ClearCart(String username)
    {
        userCartDAO.clearCart(username);
    }
}
